import { http } from "@/utils/http";
import { HttpPushForm } from "@/type/system";
type Result = {
  code: Number;
  message: string;
  result: any;
};

/** 获取网卡信息 */
export const getNetworkData = () => {
  return http.request<Result>("get", "/api/setting/network");
};

/** 获取网卡信息 */
export const setNetworkData = data => {
  return http.request<Result>("post", "/api/setting/network", { data });
};

/** 获取推送配置列表 */
export const getPushSettingsData = () => {
  return http.request<Result>("get", "/api/subscription");
};

/** 获取接收项目列表选项 */
export const getSubscriptionList = () => {
  return http.request<Result>("get", "/api/subscription/topics");
};

/** 新增推送配置 */
export const addSubscription = (data: HttpPushForm) => {
  return http.request<Result>("post", "/api/subscription", { data });
};

/** 编辑推送配置 */
export const editSubscription = (data: HttpPushForm) => {
  return http.request<Result>("put", "/api/subscription", { data });
};

/** 删除推送配置 */
export const deleteSubscription = (data: { ids: number[] }) => {
  return http.request<Result>("delete", "/api/subscription", { data });
};

/** 虚拟推送 */
export const virtualPush = (data: { id: number }) => {
  return http.request<Result>("post", "/api/subscription/test", { data });
};

/** 获取版本信息 */
export const getVersionData = () => {
  return http.request<Result>("get", "/api/version");
};

/** 获取数据清理配置 */
export const getDataCleaning = () => {
  return http.request<Result>("get", "/api/alarm/setting");
};

/** 修改数据清理配置 */
export const editDataCleaning = (data: {
  open_cleanup: boolean;
  cleanup_days: number;
}) => {
  return http.request<Result>("post", "/api/alarm/setting", { data });
};

/** 删除告警数据 */
export const deleteAlarmData = (data: { days: number }) => {
  return http.request<Result>("delete", "/api/alarm", { data });
};

/** 获取云存储支持 */
export const getCloudStorageSupport = () => {
  return http.request<Result>("get", "/api/setting/storage/drivers");
};

/** 获取储存配置 */
export const getStorageSetting = () => {
  return http.request<Result>("get", "/api/setting/storage");
};

/** 修改储存配置 */
export const editStorageSetting = data => {
  return http.request<Result>("post", "/api/setting/storage", { data });
};

/** 重启系统 */
export const restartSystem = () => {
  return http.request<Result>("post", "/api/reboot");
};
